var t = require("../../../@babel/runtime/helpers/defineProperty"), e = getApp();

Component({
    options: {
        addGlobalClass: !0
    },
    properties: {
        show: Boolean,
        data: Object
    },
    data: {
        superCouponResBg: "http://newimg.ap1983.com/prod/20220308/33d75f46b5c2429f9ce7ab0012403f5f.jpg",
        superCouponResCover: "http://newimg.ap1983.com/prod/20220308/c17bd55533e74671bd43a95d03acd975.png"
    },
    lifetimes: {
        attached: function() {
            this.startTimer();
        },
        detached: function() {
            this.stopTimer();
        }
    },
    pageLifetimes: {
        show: function() {
            this.startTimer();
        },
        hide: function() {
            this.stopTimer();
        }
    },
    methods: {
        gotoDetailOnTap: function() {
            e.gotoPage("/pages/act-super-coupon/act-super-coupon"), this.setData({
                show: !1
            }), this.onClose();
        },
        onClose: function() {
            this.triggerEvent("onClose");
        },
        startTimer: function() {
            var t = this;
            this.stopTimer(), this.updateCd(), this.interval = setInterval(function() {
                t.updateCd();
            }, 1e3);
        },
        stopTimer: function() {
            this.interval && (clearInterval(this.interval), this.interval = null);
        },
        updateCd: function() {
            var e = this.data.data.localEndTime, a = new Date().getTime(), i = parseInt((e - a) / 1e3);
            i < 0 && (i = 0);
            var s = parseInt(i / 3600), o = parseInt((i - 3600 * s) / 60), n = i % 60, r = "限时：" + (s > 9 ? s : "0" + s) + "小时" + (o > 9 ? o : "0" + o) + "分" + (n > 9 ? n : "0" + n) + "秒神券失效";
            this.setData(t({}, "data.timer", r));
        }
    }
});